package model.dao;

import java.sql.ResultSet;
import java.util.ArrayList;

import controller.util.ControllerHelper;

import model.pojo.AdminSanPhamPOJO;
import model.util.DataHelper;





public class AdminSanPhamDAO {
	public static ArrayList<AdminSanPhamPOJO> LayDSSanPham()
	{
		ArrayList<AdminSanPhamPOJO> arr = new ArrayList<AdminSanPhamPOJO>();
		DataHelper helper = new DataHelper();
        try
        {
            
            helper.open();
            ArrayList<Object> para = new ArrayList<Object>();	
            String stored = ControllerHelper.getStoreProcedureString("DSSanPham");
            ResultSet result = helper.executeProcedure(stored, para);
            
            while(result.next())
            {	        
            	AdminSanPhamPOJO sp = new AdminSanPhamPOJO();
            	sp.setDongSanPham(result.getString("MoTa"));
            	sp.setGiaBan(result.getInt("GiaBan"));
            	//sp.setLinkChiTiet(linkChiTiet);
            	sp.setLoaiSanPham(result.getString("TenLoaiSanPham"));
            	sp.setMaSanPham(result.getString("MaSP"));
            	sp.setMoTaSanPham(result.getString("MoTaSP"));
            	sp.setNhaSanXuat(result.getString("TenHangSX"));
            	sp.setTenSanPham(result.getString("TenSP"));
            	//sp.setHinhAnh("../"+result.getString("Link"));
            	arr.add(sp);
            }
        }
        catch(Exception ex)
        {
        	//kq=false;
           // System.out.println(ex.getMessage());
        }
        finally
        {
            helper.close();
        }
		return arr;
	}
}
